<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<title>vue</title>
        <!-- 引入vue文件-->
		<script src="https://cdn.bootcss.com/vue/2.2.2/vue.min.js"></script>
	</head>
	<style>
		#sign{
			width:100px;
			height: 100px;
			background: red;
		}
		.fade-enter-active, .fade-leave-active {
		  transition: opacity .5s;
		}
		.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
		  opacity: 0;
		}
	</style>
	<body>
		<div id="vue">
			<button @click="toggle">{{btnName}}</button>
			<transition name="fade">
				<div id="sign" v-if="flag" transition="fade" ></div>
			</transition>
		</div>
	</body>
	<script type="application/javascript">
		new Vue({
			el:'#vue',
			data:{
				btnName:'切换',
				flag:true
			},
			methods:{
				toggle:function(){
					this.flag=!this.flag;
				}
			}
		})
	</script>
</html>
